package com.example.homeworkmutualevaluation.Service;

import com.example.homeworkmutualevaluation.Dao.DiscussDao;
import com.example.homeworkmutualevaluation.Entity.Discuss;
import com.example.homeworkmutualevaluation.utils.UniqueId;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscussService {
    @Resource
    private DiscussDao discussDao;
    public List<Discuss> findAllByHomeworkid(int homeworkid) {
        return discussDao.findAllByHomeworkid(homeworkid);
    }

    public String insert(String sphone, int homeworkid, String content) {
        String id = UniqueId.next();
        if (discussDao.insert(id, sphone, homeworkid, content) > 0) return id;
        return null;
    }

    public boolean delete(String discussid) {
        return discussDao.delete(discussid) > 0;
    }
}
